package br.it.teste.modelo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import br.it.teste.banco.BancoHelper;

public class Meliante {

	//...
	private String nome;
	private Arma arma;
	
	public Meliante(){
		super();
	}
	
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public Arma getArma() {
		return arma;
	}
	public void setArma(Arma arma) {
		this.arma = arma;
	}

	public boolean inserir() {
		boolean salvo = true;
		
		try {

			Connection conexao = BancoHelper.getConexao();
			
			String sql = "INSERT INTO Criminoso VALUES (?, ?); ";
			PreparedStatement stmt = conexao.prepareStatement(sql);
			stmt.setString(1, this.nome);
			stmt.setInt(2, this.arma.getId() );

//			stmt.execute(); //Consertar a comando SQL

			conexao.close();

		} catch (SQLException e) {
			System.out.println("Erro de SQL!");
			salvo = false;
		}
		
		return salvo;
			
		
	}
	
}
